<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<script type="text/javascript">
			var isPerfectSquare = function (num) {
			    // 1+3+5+..+2n-1 = n^2
			    let i = 1
			    while (num > 0) {
			        num -= i
			        i += 2
			    }
			    // 如果等于0，则满足题意
			    return num === 0
			};
			console.log(isPerfectSquare(16));
		</script>
	</body>
</html>
